import request, { type ListQuery, type ListResponse } from "@/utils/request";
import { type CityType } from "../system/city";

const AGENT_BASE_URL = "/api";

export const AgentApi = {
  getAgentList: (params: ListQuery) => {
    return request.get<any, ListResponse<AgentItemType>>(`${AGENT_BASE_URL}/agent/`, {
      params,
    });
  },
};

export type AgentListQuery = {
  search: string;
} & ListQuery;

export type AgentItemType = {
  id: number;
  user: {
    id: number;
    username: string;
    avatar_url: string;
    nickname: string;
  };
  city: CityType;
  province: CityType;
  district: CityType;
  created_at: string;
  updated_at: string;
  is_active: boolean;
  name: string;
  invitation_code: string;
};

export type AgentForm = {
  id?: number;
  user: number | string;
  agent: number | string;
  name: string;
  contact_name: string;
  contact_phone: string;
  contact_email: string;
  is_active: boolean;
};

export default AgentApi;
